import axios from "axios";// 通过axios框架导入axios

// 创建axios实例
const instance = axios.create({
    baseURL: "https://api.uomg.com/",
    timeout: 100000
})

// 添加请求拦截器
instance.interceptors.request.use(
    function(config){
        console.log('before request!')
        config.headers.Accept = "application/json, text/plain, text/html */*"
        return config
    }
    ,
    function(error){
        console.log('request error')
        return Promise.reject(error)
    }
)

// 添加响应拦截器
instance.interceptors.response.use(
    function(response) {
        console.log('after success response')
        console.log(response)
        return response
    }
    ,
    function(error){
        console.log('after fail response')
        console.log(error)
        return Promise.reject(error)
    }
)

export default instance